#    SUSAN® - Sole of Unix Save ANything
#
#   Copyright (C) 2019-2020 Hechzh Property
#
#   This program is Free Software; you can redistribute it and/or
#   modify it under the terms of version three of the GNU Affero General Public
#   License as published by the Free Software Foundation and included
#   in the file LICENSE.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#   Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#   02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")

file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/AppCenter/")

file(
  COPY "AppCenter/LICENSE_AGREEMENT"
       "AppCenter/README"
       "AppCenter/README_DE"
       "AppCenter/susan-webui_screenshot.png"
       "../../src/images/susan-logo.svg"
       "../../src/images/susan-logo-full.svg"
  DESTINATION "${CMAKE_SOURCE_DIR}/AppCenter/"
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/conffiles/"
     DESTINATION "${CMAKE_SOURCE_DIR}/conffiles/"
)

add_custom_command(
  OUTPUT univention-install-config-registry
  COMMAND
    ${CMAKE_SOURCE_DIR}/core/platforms/univention/create_ucs_template_files.sh
    conffiles/
  COMMAND univention-install-config-registry -v
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

add_custom_target(run ALL DEPENDS univention-install-config-registry)

install(
  FILES "job-generic.template"
  DESTINATION "${confdir}/autogenerated/clients/"
  RENAME "generic.template"
)

install(
  FILES "job-windows.template"
  DESTINATION "${confdir}/autogenerated/clients/"
  RENAME "windows.template"
)

install(
  # This file contains the Susan repository signature public. During the
  # automatic build process, It will be added. For manual builds, download the
  # file from
  # http://download.susan.org/susan/release/<RELEASE>/<DISTRIBUTION>/Release.k
  # ey
  FILES "susan-release.key"
  DESTINATION "${confdir}"
)

install(
  FILES "univention-susan.cron"
  RENAME "univention-susan"
  DESTINATION "${sysconfdir}/cron.d/"
)

install(FILES "univention-susan.py"
        DESTINATION "/usr/lib/univention-directory-listener/system/"
)

install(PROGRAMS "62univention-susan.inst"
        DESTINATION "/usr/lib/univention-install/"
)

install(PROGRAMS "63univention-susan.uinst"
        DESTINATION "/usr/lib/univention-uninstall/"
)

install(FILES "univention-susan.schema"
        DESTINATION "/usr/share/univention-susan/"
)

install(PROGRAMS "susan-dir-restart" "susan-dir-restart-on-change"
        DESTINATION "/usr/share/univention-susan/"
)

install(CODE "set(CMAKE_SOURCE_DIR \"${CMAKE_SOURCE_DIR}\")")
install(
  SCRIPT
    ${CMAKE_SOURCE_DIR}/core/cmake/install-univention-extra-configuration.cmake
)
